require("knitr")
knitr::opts_chunk$set(warning=FALSE, message=FALSE, fig.align='center')

###############
# Carbon and Nitrogen Isotopic Analysis of Individual Amino Acids in Montipora capitata
# Author: C. Wall
# Collaborators: Brian Popp, Ruth Gates
# Institution: University of Hawai'i at Mānoa
###############

# load packages
library(devtools)
#install_github("ggbiplot", "vqv")
library(ggbiplot)
require(graphics)
library(dplyr)
library("effects")
library(plyr)
library(plotrix)
library("cowplot")

Background

Techniques for Compound Specific Isotope Analysis (CSIA) of individual amino acids (AA) have been developed to better understand ecosystem food webs, trophic positions, and sources of nutrition in biological samples ranging from bacteria to ceteceans. Bulk tissue isotope analysis requires separate accounting for isotopic signatures at the base of the food web, which vary in across locations and time periods. However, CSIA can account for both source and trophic isotope effects in a single sample of a consumer’s tissue.

Source amino acids are a group of AA that exhibit little change in isotopic composition with increasing trophic levels and reflect the isotopic composition of the ‘source material’ at the base of the food web from which they originated.

Trophic amino acids on the other hand are a group of AA that show significant 15N enrichment compared to source-AA, which correspond to trophic steps.This enrichment is quite large and may exceed 8 ‰.

Carbon

Carbon in amino acids of plankton, Symbiodinium and coral host tissues.

######## ######## 
## Carbon 
######## ######## 
rm(list=ls())
d13C.dat<-read.csv("data/d13C.CSIA.wide.csv") # wide form carbon data

colnames(d13C.dat)
d13C.dat$Fraction<-factor(d13C.dat$Fraction, levels=c("host", "symb", "plank"))
d13C.dat<-d13C.dat[ , !(names(d13C.dat) %in% c("Norleucine", "Aminoadipic.Acid", "Methionine"))] #remove Norleucine, Methionine, Aminoadipic Acid

PCA by treatment

Run a PCA looking at effects of treatment.

######## ######## ######## ######## 
######## ######## ######## ######## by treatment
# PCA dataframe
PCA.df<-d13C.dat[, c(7:8,11:23)]

PC<- prcomp(PCA.df[,c(-1:-2)], center = TRUE, scale= TRUE) 
PC.summary<-summary(PC)
ev<-PC$sdev^2 
newdat<-PC$x[,1:4] # 2 PCAs explain 76% of variance
#plot(PC, type="lines", main="PC.area eigenvalues")

## PC1 and PC2
PC.fig1 <- ggbiplot(PC, choices = 1:2, obs.scale = 1, var.scale = 1, 
                             groups= PCA.df[,1], ellipse = TRUE,
                             circle = FALSE) +
  scale_color_discrete(name = '') +
  theme_bw() +
  scale_x_continuous(breaks=pretty_breaks(n=5))+
  coord_cartesian(xlim = c(-8, 8), ylim=c(-4, 4))+ 
  theme(axis.ticks.length=unit(-0.25, "cm"), axis.text.y=element_text(margin=unit(c(0.5, 0.5, 0.5, 0.5), "cm")), axis.text.x=element_text(margin=unit(c(0.5, 0.5, 0.5, 0.5), "cm"))) +
  theme(legend.text=element_text(size=15)) +
  theme(panel.background = element_rect(colour = "black", size=1))+
  theme(legend.key = element_blank())+
  theme(legend.direction = 'horizontal', legend.position = 'top') +theme(aspect.ratio=0.7)
print(PC.fig1)

ggsave("figures/carbon/PCA_d13C.trt.pdf", height=5, width=8, encod="MacRoman")

PCA by fraction

Run a new PCA looking at the effects of fraction (plankton, host, symbiont)

######## ######## ######## ######## 
######## ######## ######## ######## by fraction

PC.fig2 <- ggbiplot(PC, choices = 1:2, obs.scale = 1, var.scale = 1, 
                   groups= PCA.df[,2], ellipse = TRUE,
                   circle = FALSE) +
  scale_color_discrete(name = '') +
  theme_bw() +
  coord_cartesian(xlim = c(-8, 8), ylim=c(-4, 4)) +
  theme(axis.ticks.length=unit(-0.25, "cm"), axis.text.y=element_text(margin=unit(c(0.5, 0.5, 0.5, 0.5), "cm")), axis.text.x=element_text(margin=unit(c(0.5, 0.5, 0.5, 0.5), "cm"))) +
  theme(legend.text=element_text(size=15)) +
  theme(panel.background = element_rect(colour = "black", size=1))+
  theme(legend.key = element_blank())+
  theme(legend.direction = 'horizontal', legend.position = 'top') +theme(aspect.ratio=0.7)
print(PC.fig2)

ggsave("figures/carbon/PCA_d13C.frac.pdf", height=5, width=8, encod="MacRoman")

Models

Run models looking for effects of Fraction or the Treatment-Interaction (feeding/light).

d13C.dat2<-d13C.dat[!(d13C.dat$Fraction=="plank"),] #remove plankton for now

for(i in c(11:23)){
  Y=d13C.dat2[,i]
  mod<-aov(Y~Fraction+Treat.Int, data=d13C.dat2)
  print(anova(mod))
  plot(allEffects(mod), ylab=colnames(d13C.dat2)[i], cex.axis=0.5, cex.lab=0.5)
}
## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value  Pr(>F)  
## Fraction   1  7.9280  7.9280  4.8489 0.05881 .
## Treat.Int  2  2.3861  1.1931  0.7297 0.51157  
## Residuals  8 13.0802  1.6350                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

## Analysis of Variance Table
## 
## Response: Y
##           Df Sum Sq Mean Sq F value   Pr(>F)   
## Fraction   1 43.514  43.514  16.281 0.003762 **
## Treat.Int  2 38.910  19.455   7.279 0.015818 * 
## Residuals  8 21.382   2.673                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

## Analysis of Variance Table
## 
## Response: Y
##           Df Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  2.197  2.1971  0.4464 0.5228
## Treat.Int  2  5.526  2.7628  0.5614 0.5914
## Residuals  8 39.372  4.9215

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  0.5098  0.5098  0.1910 0.6736
## Treat.Int  2 13.3334  6.6667  2.4977 0.1436
## Residuals  8 21.3529  2.6691

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  3.0549  3.0549  1.2730 0.2919
## Treat.Int  2  4.4772  2.2386  0.9328 0.4324
## Residuals  8 19.1986  2.3998

## Analysis of Variance Table
## 
## Response: Y
##           Df Sum Sq Mean Sq F value Pr(>F)
## Fraction   1 0.1806 0.18060  0.1457 0.7126
## Treat.Int  2 1.8191 0.90953  0.7340 0.5097
## Residuals  8 9.9129 1.23912

## Analysis of Variance Table
## 
## Response: Y
##           Df Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  2.301  2.3006  0.5090 0.4958
## Treat.Int  2  0.536  0.2681  0.0593 0.9428
## Residuals  8 36.157  4.5196

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value  Pr(>F)  
## Fraction   1 10.0959 10.0959  5.0226 0.05533 .
## Treat.Int  2  1.9626  0.9813  0.4882 0.63089  
## Residuals  8 16.0806  2.0101                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  1.9366 1.93656  0.8704 0.3781
## Treat.Int  2  1.1095 0.55476  0.2494 0.7851
## Residuals  8 17.7984 2.22480

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value   Pr(>F)   
## Fraction   1 15.4184 15.4184 15.5000 0.004314 **
## Treat.Int  2  7.1774  3.5887  3.6077 0.076423 . 
## Residuals  8  7.9579  0.9947                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  0.4717 0.47171  0.3402 0.5758
## Treat.Int  2  1.7167 0.85836  0.6190 0.5624
## Residuals  8 11.0933 1.38666

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  0.4274 0.42736  0.2195 0.6519
## Treat.Int  2  3.7940 1.89702  0.9743 0.4181
## Residuals  8 15.5772 1.94716

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  0.7150 0.71500  0.4577 0.5178
## Treat.Int  2  0.0828 0.04142  0.0265 0.9739
## Residuals  8 12.4980 1.56225

# Almost Fraction effect for Alanine, Proline
# Fraction effect for: Glycine, Glutamic acid
# Treatment effect for: Glycine
# Almost Treatment effect: Glutamic Acid

-New dataframe (long format) here to make figures. Same data as above.

###########
###########
# CSAA.dat long

d13C.dat.long<-read.csv("data/d13C.CSIA.long.csv")
#str(d13C.dat.long)

d13C.dat.long<-d13C.dat.long[!(d13C.dat.long$Amino.acid=="Methionine"),]
d13C.dat.long<-d13C.dat.long[!(d13C.dat.long$Amino.acid=="Norleucine"),]
d13C.dat.long<-d13C.dat.long[!(d13C.dat.long$Amino.acid=="Aminoadipic Acid"),] # remove unwanted data

d13C.dat.long$AA.short<-mapvalues(d13C.dat.long$Amino.acid, from =c("Alanine", "Aspartic acid", "Glutamic acid", "Glycine", "Isoleucine", "Leucine", "Lysine", "Phenylalanine", "Proline", "Serine", "Threonine", "Tyrosine", "Valine"), to = c("Ala", "Asp", "Glu", "Gly", "Ile", "Leu", "Lys", "Phe", "Pro", "Ser", "Thr", "Tyr", "Val"))

d13C.dat.long$AA.short<-factor(d13C.dat.long$AA.short, levels=c("Ala","Asp", "Glu", "Ile", "Leu", "Pro", "Val", "Gly", "Lys", "Ser", "Phe", "Thr", "Tyr"))

# looking at average trophic and source AA
# trophic example = glutamate, source = phenylalanine
# Source AA  not enriched with trophic transfers
# Trophic AA change with trophic transfers... these are the ones below

d13C.dat.long$AA.cat<-ifelse(d13C.dat.long$AA.short=="Asp" | d13C.dat.long$AA.short=="Glu" | 
                               d13C.dat.long$AA.short=="Ala" | d13C.dat.long$AA.short=="Ile" | 
                               d13C.dat.long$AA.short=="Leu" | d13C.dat.long$AA.short=="Val" | 
                               d13C.dat.long$AA.short=="Pro", "Troph", "Source")

mod<-lm(d13C.value~AA.short+Treat.Int*Fraction, data=d13C.dat.long)
plot(allEffects(mod), par.strip.text=list(cex=0.7), par.settings=list(axis.text=list(cex=0.7)))

dfC<-d13C.dat.long
dfC<-dfC[!(dfC$AA.short == "Thr"), ] # removing Thr because not source or trophic

Figures

  • all AA pooled across fractions, showing d13C.CSIA_Fraction
######## Figures
df.mean<-aggregate(d13C.value~AA.short+Fraction, data=dfC, mean, na.rm=TRUE)
df.n<-aggregate(d13C.value~AA.short+Fraction, data=dfC, length)
df.SD<-aggregate(d13C.value~AA.short+Fraction, data=dfC, sd, na.rm=TRUE)
colnames(df.SD)[3]="SD"
df.mean<-cbind(df.mean, df.SD[3])
df.mean$Fraction<-factor(df.mean$Fraction, levels=c("host", "symb", "plank"))


Fig.formatting<-(theme_classic()) +
  theme(text=element_text(size=10),
        axis.line=element_blank(),
        legend.text.align = 0,
        legend.text=element_text(size=10),
        #legend.title = element_blank(),
        panel.border = element_rect(fill=NA, colour = "black", size=1),
        aspect.ratio=1, 
        axis.ticks.length=unit(0.25, "cm"),
        axis.text.y=element_text(
          margin=unit(c(0.5, 0.5, 0.5, 0.5), "cm"), colour="black", size=10), 
        axis.text.x=element_text(
          margin=unit(c(0.5, 0.5, 0.5, 0.5), "cm"), colour="black", size=8)) +
  theme(legend.key.size = unit(0.4, "cm")) +
  theme(aspect.ratio=1) +
  theme(panel.spacing=unit(c(0, 0, 0, 0), "cm"))

######
# all AA pooled by fraction
pd <- position_dodge(0.5) #offset for error bars
ggplot(df.mean, aes(x=AA.short, y=d13C.value)) +
  geom_errorbar(aes(ymin=d13C.value-SD, ymax=d13C.value+SD, color=Fraction), 
                size=.5, width=0, position=pd) +
  geom_point(size=3, pch=19,  position=pd, aes(color=Fraction)) +
  geom_vline(xintercept=7.5, linetype="solid", color = "gray") +
  annotate(geom="text", label="Trophic-AA", x=4.0, y=0, color="gray40") +
  annotate(geom="text", label="Source-AA", x=10.0, y=0, color="gray40") +
  ggtitle(expression(paste(delta^{13}, C[AA], " by biological fraction"))) +
         coord_cartesian(ylim=c(-35, 0)) + 
  xlab("Amino Acids") + 
  ylab(ylab(expression(paste(delta^{13}, C[AA], " (\u2030, V-PDB)")))) +
  scale_color_manual(values=c("coral", "springgreen3", "skyblue3")) +
         Fig.formatting

ggsave("figures/carbon/d13C.CSIA_Fraction.pdf", height=5, width=8, encod="MacRoman")
  • d13C by fraction and treatments, showing d13C.CSIA_frac.trt
#################
#################
# d13C by fraction and treatments

df.mean<-aggregate(d13C.value~AA.short+Fraction+Treat.Int, data=dfC, mean, na.rm=TRUE)
df.n<-aggregate(d13C.value~AA.short+Fraction+Treat.Int, data=dfC, length)
df.SD<-aggregate(d13C.value~AA.short+Fraction+Treat.Int, data=dfC, sd, na.rm=TRUE)
colnames(df.SD)[4]="SD"
df.mean<-cbind(df.mean, df.SD[4])
df.mean$Fraction<-factor(df.mean$Fraction, levels=c("host", "symb", "plank"))


pd <- position_dodge(0.0) #offset for error bars
ggplot(df.mean, aes(x=AA.short, y=d13C.value)) +
  geom_point(size=3, position=pd, aes(shape=Treat.Int, color=Fraction, group=Treat.Int)) +
  ggtitle(expression(paste(delta^{13}, C[AA], " by biological fraction and treatment"))) +
  geom_vline(xintercept=7.5, linetype="solid", color = "gray") +
  annotate(geom="text", label="Trophic-AA", x=4, y=0, color="gray40") +
  annotate(geom="text", label="Source-AA", x=10, y=0, color="gray40") +
  coord_cartesian(ylim=c(-35, 0)) + 
  xlab("Amino Acids") +
  scale_color_manual(values=c("coral", "springgreen3", "skyblue3")) +
  ylab(ylab(expression(paste(delta^{13}, C[AA], " (\u2030, V-PDB)")))) +
  Fig.formatting

ggsave("figures/carbon/d13C.CSIA_frac.trt.pdf", height=5, width=8, encod="MacRoman")
  • all d13C amino acids: showing d13C.CSIA_Trt.alone
##################
# all d13C amino acids

df.mean2<-aggregate(d13C.value~AA.short+Treat.Int, data=dfC, mean, na.rm=TRUE)
df.SD2<-aggregate(d13C.value~AA.short+Treat.Int, data=dfC, na.rm=TRUE, sd)
df.SD2[is.na(df.SD2)] <- 0
colnames(df.SD2)[3]="SD"
df.mean2<-cbind(df.mean2, df.SD2[3])

pd <- position_dodge(0.5) #offset for error bars
ggplot(df.mean2, aes(x=AA.short, y=d13C.value, group=Treat.Int)) +
  geom_errorbar(aes(ymin=d13C.value-SD, ymax=d13C.value+SD, color=Treat.Int), size=.5, width=0, position=pd) +
  geom_point(aes(color=Treat.Int), size=3, position=pd) +
  ggtitle(expression(paste(delta^{13}, C[AA], " by treatment"))) +
  geom_vline(xintercept=7.5, linetype="solid", color = "gray") +
  annotate(geom="text", label="Trophic-AA", x=4, y=0, color="gray40") +
  annotate(geom="text", label="Source-AA", x=10, y=0, color="gray40") +
  coord_cartesian(ylim=c(-35, 0)) + 
  xlab("Amino Acids") +
  scale_color_manual(values=c("gray40", "darkgoldenrod1", "coral", "skyblue2")) +
  ylab(ylab(expression(paste(delta^{13}, C[AA], " (\u2030, V-PDB)")))) +
  Fig.formatting

ggsave("figures/carbon/d13C.CSIA_Trt.alone.pdf", height=5, width=8, encod="MacRoman")

Trophic and source AA

##################
# all trophic and source AA
AA.means<-aggregate(d13C.value~AA.cat+Treat.Int+Fraction, data=dfC, mean, na.rm=TRUE); AA.means
AA.sd<-aggregate(d13C.value~AA.cat+Treat.Int+Fraction, data=dfC, sd, na.rm=TRUE)
colnames(AA.sd)[4]="SD"
AA.means<-cbind(AA.means, AA.sd[4])
AA.means$Fraction<-factor(AA.means$Fraction, levels=c("host", "symb", "plank"))


pd <- position_dodge(0.5) #offset for error bars
ggplot(AA.means, aes(x=Treat.Int, y=d13C.value, group=AA.cat, color=Fraction)) +
  geom_errorbar(aes(ymin=d13C.value-SD, ymax=d13C.value+SD), size=.5, width=0, position=pd) +
  geom_point(aes(color=Fraction, shape=AA.cat), size=3, position=pd) +
  ggtitle(expression(paste(delta^{13}, C[AA], " by biological fraction and Trophic/Source-AA"))) +
  coord_cartesian(ylim=c(-30, -5)) + 
  scale_x_discrete(name ="Treatments", 
                   labels=c("Dark\nFed", "Light\nFed", "Light\nNot Fed", "Plankton")) +
  scale_color_manual(values=c("coral", "skyblue3", "springgreen3")) +
  ylab(ylab(expression(paste(delta^{13}, C[AA], " (\u2030, V-PDB)")))) +
  Fig.formatting

ggsave("figures/carbon/d13C.CSIA_TrSo.pdf", height=5, width=8, encod="MacRoman")
  • source AA glycine, serine, and threonine removed, showing 13C.CSIA.no.glyserthr
##################
# source AA glycine and serine removed also threonine
dfC.trim<-d13C.dat.long[!(d13C.dat.long$AA.short=="Ser" | 
                            d13C.dat.long$AA.short=="Gly" | 
                            d13C.dat.long$AA.short=="Thr"),]

AA.means<-aggregate(d13C.value~AA.cat+Treat.Int+Fraction, data=dfC.trim, mean, na.rm=TRUE)
AA.sd<-aggregate(d13C.value~AA.cat+Treat.Int+Fraction, data=dfC.trim, na.rm=TRUE, sd)
colnames(AA.sd)[4]="SD"
AA.means<-cbind(AA.means, AA.sd[4])
AA.means$Fraction<-factor(AA.means$Fraction, levels=c("host", "symb", "plank"))

pd <- position_dodge(0.5) #offset for error bars
ggplot(AA.means, aes(x=Treat.Int, y=d13C.value, group=AA.cat, color=Fraction)) +
  geom_errorbar(aes(ymin=d13C.value-SD, ymax=d13C.value+SD), size=.5, width=0, position=pd) +
  geom_point(aes(color=Fraction, shape=AA.cat), size=3, position=pd) +
  coord_cartesian(ylim=c(-30, -5)) + 
  scale_x_discrete(name ="Treatments", 
                   labels=c("Dark\nFed", "Light\nFed", "Light\nNot Fed", "Plankton")) +
  ggtitle(expression(paste(delta^{13}, C[AA], " by fraction, Tr/So-AA, - Ser/Gly/Thr"))) +
  scale_color_manual(values=c("coral", "skyblue3", "springgreen3")) +
  ylab(ylab(expression(paste(delta^{13}, C[AA], " (\u2030, V-PDB)")))) +
  Fig.formatting

ggsave("figures/carbon/d13C.CSIA.no.glyserthr.pdf", height=5, width=8, encod="MacRoman")
  • threonine in host and symbiont (microbial source), showing d13C.CSIA_TrSo.thr
##################
# threonine in host and symbiont (microbial source)
dfC.thr<-d13C.dat.long[(d13C.dat.long$AA.short=="Thr"),]

AA.means<-aggregate(d13C.value~AA.short+Treat.Int+Fraction, data=dfC.thr, mean, na.rm=TRUE)
AA.sd<-aggregate(d13C.value~AA.short+Treat.Int+Fraction, data=dfC.trim, na.rm=TRUE, sd)
colnames(AA.sd)[4]="SD"
AA.means<-cbind(AA.means, AA.sd[4])
AA.means$Fraction<-factor(AA.means$Fraction, levels=c("host", "symb", "plank"))

ggplot(AA.means, aes(x=Treat.Int, y=d13C.value, color=Fraction)) +
  geom_errorbar(aes(ymin=d13C.value-SD, ymax=d13C.value+SD), size=.5, width=0, position=pd) +
  geom_point(aes(color=Fraction), size=3, position=pd) +
  coord_cartesian(ylim=c(0, -30)) + 
  scale_x_discrete(name ="Treatments", 
                   labels=c("Dark\nFed", "Light\nFed", "Light\nNot Fed", "Plankton")) +
  ggtitle(expression(paste("Threonine ", delta^{13}, C[AA]))) +
  scale_color_manual(values=c("coral", "springgreen3", "skyblue3")) +
  ylab(ylab(expression(paste(delta^{13}, C[AA], " (\u2030, v-PDB)")))) +
  Fig.formatting

ggsave("figures/carbon/d13C.CSIA_TrSo.thr.pdf", height=5, width=8, encod="MacRoman")

Nitrogen

######## ######## 
## Nitrogen 
######## ######## 
d15N.dat<-read.csv("data/d15N.CSIA.wide.csv") # wide form carbon data
d15N.dat<-d15N.dat[ , !(names(d15N.dat) %in% c("Norleucine", "Aminoadipic.Acid", "Methionine"))]
d15N.dat$Fraction<-factor(d15N.dat$Fraction, levels=c("host", "symb", "plank"))

PCA by treatment

# PCA dataframe
PCA.df<-d15N.dat[, c(7:8,11:23)]
PC<- prcomp(PCA.df[, c(-1:-2)], center = TRUE, scale= TRUE) 
PC.summary<-summary(PC)
ev<-PC$sdev^2 
newdat<-PC$x[,1:4] # 2 PCAs explain 74% of variance
#plot(PC, type="lines", main="PC.area eigenvalues")

######################## treatments
## PC1 and PC2
PC.fig3 <- ggbiplot(PC, choices = 1:2, obs.scale = 1, var.scale = 1, 
                   groups= PCA.df[,1], ellipse = TRUE,
                   circle = FALSE) +
  scale_color_discrete(name = '') +
  theme_bw() +
  coord_cartesian(xlim = c(-8, 5), ylim=c(-6, 6)) +
  theme(axis.ticks.length=unit(-0.25, "cm"), axis.text.y=element_text(margin=unit(c(0.5, 0.5, 0.5, 0.5), "cm")), axis.text.x=element_text(margin=unit(c(0.5, 0.5, 0.5, 0.5), "cm"))) +
  theme(legend.text=element_text(size=15)) +
  theme(panel.background = element_rect(colour = "black", size=1))+
  theme(legend.key = element_blank())+
  theme(legend.direction = 'horizontal', legend.position = 'top') +theme(aspect.ratio=0.7)
print(PC.fig3)

ggsave("figures/nitrogen/PCA_d15N.trt.pdf", height=5, width=8, encod="MacRoman")

PCA by fraction

######################### fractions
## PC1 and PC2
PC.fig4 <- ggbiplot(PC, choices = 1:2, obs.scale = 1, var.scale = 1, 
                   groups= PCA.df[,2], ellipse = TRUE,
                   circle = FALSE) +
  scale_color_discrete(name = '') +
  theme_bw() +
  coord_cartesian(xlim = c(-8, 5), ylim=c(-6, 6)) + 
  theme(axis.ticks.length=unit(-0.25, "cm"), axis.text.y=element_text(margin=unit(c(0.5, 0.5, 0.5, 0.5), "cm")), axis.text.x=element_text(margin=unit(c(0.5, 0.5, 0.5, 0.5), "cm"))) +
  theme(legend.text=element_text(size=15)) +
  theme(panel.background = element_rect(colour = "black", size=1))+
  theme(legend.key = element_blank())+
  theme(legend.direction = 'horizontal', legend.position = 'top') +theme(aspect.ratio=0.7)
print(PC.fig4)

ggsave("figures/nitrogen/PCA_d15N.frac.pdf", height=5, width=8, encod="MacRoman")
  • arrange the 4 plots:
#### compile the 4 PCA ###
library("cowplot")
plot_grid(PC.fig1, PC.fig3, PC.fig2, PC.fig4, ncol = 2)

ggsave("figures/PCAs.pdf", height=8, width=11, encod="MacRoman")

######

models

Overall we see:
- Fraction effect for: Leucine, Proline, Aspartic Acid, Glutamic Acid, Tyrosine.
- Treatment effect for: Leucine

d15N.dat2<-d15N.dat[!(d15N.dat$Fraction=="plank"),] #remove plankton for now

for(i in c(11:23)){
  Y=d15N.dat2[,i]
  mod<-aov(Y~Fraction+Treat.Int, data=d15N.dat2)
  print(anova(mod), cex=0.5)
  plot(allEffects(mod), ylab=colnames(d15N.dat2)[i], cex.axis=0.5)
}
## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  8.1676  8.1676  3.3922 0.1028
## Treat.Int  2  1.8579  0.9290  0.3858 0.6919
## Residuals  8 19.2618  2.4077

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  4.2262  4.2262  1.6503 0.2349
## Treat.Int  2  1.5693  0.7846  0.3064 0.7444
## Residuals  8 20.4868  2.5609

## Analysis of Variance Table
## 
## Response: Y
##           Df Sum Sq Mean Sq F value Pr(>F)
## Fraction   1 13.327 13.3269  2.6576 0.1417
## Treat.Int  2  3.612  1.8061  0.3602 0.7083
## Residuals  8 40.117  5.0147

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  0.0006 0.00062  0.0003 0.9860
## Treat.Int  2  1.6612 0.83058  0.4397 0.6589
## Residuals  8 15.1127 1.88908

## Analysis of Variance Table
## 
## Response: Y
##           Df Sum Sq Mean Sq F value Pr(>F)
## Fraction   1 0.2248 0.22482  0.2201 0.6515
## Treat.Int  2 0.0415 0.02076  0.0203 0.9799
## Residuals  8 8.1699 1.02123

## Analysis of Variance Table
## 
## Response: Y
##           Df Sum Sq Mean Sq F value   Pr(>F)   
## Fraction   1 9.9952  9.9952 19.9043 0.002107 **
## Treat.Int  2 3.8088  1.9044  3.7924 0.069430 . 
## Residuals  8 4.0173  0.5022                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  0.3383  0.3383  0.0908 0.7708
## Treat.Int  2  3.8576  1.9288  0.5178 0.6145
## Residuals  8 29.8002  3.7250

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## Fraction   1 22.9354 22.9354 28.9356 0.0006623 ***
## Treat.Int  2  4.1174  2.0587  2.5973 0.1351371    
## Residuals  8  6.3411  0.7926                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

## Analysis of Variance Table
## 
## Response: Y
##           Df Sum Sq Mean Sq F value  Pr(>F)  
## Fraction   1 3.3328  3.3328  6.3165 0.03619 *
## Treat.Int  2 1.4198  0.7099  1.3455 0.31354  
## Residuals  8 4.2210  0.5276                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

## Analysis of Variance Table
## 
## Response: Y
##           Df Sum Sq Mean Sq F value Pr(>F)
## Fraction   1 1.1145 1.11452  2.3608 0.1630
## Treat.Int  2 0.9348 0.46741  0.9901 0.4129
## Residuals  8 3.7768 0.47210

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  1.4002 1.40019  0.5355 0.4852
## Treat.Int  2  0.8007 0.40036  0.1531 0.8605
## Residuals  8 20.9164 2.61455

## Analysis of Variance Table
## 
## Response: Y
##           Df Sum Sq Mean Sq F value  Pr(>F)  
## Fraction   1 16.163  16.163  8.9499 0.01729 *
## Treat.Int  2  0.128   0.064  0.0354 0.96532  
## Residuals  8 14.448   1.806                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

## Analysis of Variance Table
## 
## Response: Y
##           Df  Sum Sq Mean Sq F value Pr(>F)
## Fraction   1  0.1051 0.10513  0.0799 0.7846
## Treat.Int  2  0.2452 0.12259  0.0931 0.9120
## Residuals  8 10.5298 1.31623

# Fraction effect for: Leucine, Proline, Aspartic Acid, Glutamic Acid, Tyrosine
# Treatment effect for: Leucine
Trophic position

Trophic position using trophic AA gultamic acid (Glu) and source amino acid phenylalanine (Phe), following Chikaraishi et al. 2009

\(Trophic~position~(TP){_C}{_S}{_I}{_A}= [(δ{^1}{^5}N{_T}{_r}{_p}~-~δ{^1}{^5}N{_S}{_r}{_c})-B/~TDF{_A}{_A} +1\) - Trophic Position, showing TP.glu.phe

###
# scatter of glutamic.acid vs. phenylalanine
 
       
### ### ### 
### ### ### trophic position using trophic (Glu) and source (Phe) AA, Chikaraishi et al. 2009

d15N.dat # dataframe here
# glu = trophic AA (changing with food,  show enrichment realtive to source
# phe = source AA (showlittle change with increasing trophic position, reflect d15N baseline)
# beta = 3.4 (difference in d15N values among trophic and source AAs in primary producers, @ TP=1)
# TDFAA = trophic discrimination factor: mean 15N enrichment of >=1 trophic vs. source AA per trophic level
 
d15N.dat<-d15N.dat %>% mutate(TP = ((Glutamic.acid - Phenylalanine - 3.4)/7.6) +1)

df.mean<-aggregate(TP~Treat.Int+Fraction, data=d15N.dat, mean, na.rm=TRUE)
df.SD<-aggregate(TP~Treat.Int+Fraction, data=d15N.dat, sd, na.rm=TRUE)
colnames(df.SD)[3]="SD"
df.mean<-cbind(df.mean, df.SD[3])
df.mean$Fraction<-factor(df.mean$Fraction, levels=c("host", "symb", "plank"))

ggplot(df.mean, aes(x=Treat.Int, y=TP)) +
  geom_errorbar(aes(ymin=TP-SD, ymax=TP+SD, color=Fraction), 
                size=.5, width=0, position=pd) +
  geom_point(size=3, pch=19,  position=pd, aes(color=Fraction)) +
  ggtitle("Chikaraishi trophic position") +
  coord_cartesian(ylim=c(2.5, 0.5)) +
  scale_x_discrete(name ="Treatments", 
                   labels=c("Dark\nFed", "Light\nFed", "Light\nNot Fed", "Plankton")) +
  ylab(ylab(expression(paste("TP "~delta^{15}, N[Glu-Phe], " (\u2030, AIR)")))) +
  scale_color_manual(values=c("coral", "springgreen3", "skyblue3")) +
  Fig.formatting

ggsave("figures/nitrogen/TP.glu.phe.pdf", height=5, width=8, encod="MacRoman")
###########
###########
# d15N.CSIA.dat long
d15N.dat.long<-read.csv("data/d15N.CSIA.long.csv")

#str(d15N.dat.long)

d15N.dat.long<-d15N.dat.long[!(d15N.dat.long$Amino.acid=="Methionine"),]
d15N.dat.long<-d15N.dat.long[!(d15N.dat.long$Amino.acid=="Norleucine"),]
d15N.dat.long<-d15N.dat.long[!(d15N.dat.long$Amino.acid=="Aminoadipic Acid"),] # remove unwanted data

d15N.dat.long$AA.short<-mapvalues(d15N.dat.long$Amino.acid, from =c("Alanine", "Aspartic acid", "Glutamic acid", "Glycine", "Isoleucine", "Leucine", "Lysine", "Phenylalanine", "Proline", "Serine", "Threonine", "Tyrosine", "Valine"), to = c("Ala", "Asp", "Glu", "Gly", "Ile", "Leu", "Lys", "Phe", "Pro", "Ser", "Thr", "Tyr", "Val"))

d15N.dat.long$AA.short<-factor(d15N.dat.long$AA.short, levels=c("Ala","Asp", "Glu", "Ile", "Leu", "Pro", "Val", "Gly", "Lys", "Ser", "Phe", "Thr", "Tyr"))

# looking at average Trophic and Source
d15N.dat.long$AA.cat<-ifelse(d15N.dat.long$AA.short=="Asp" | d15N.dat.long$AA.short=="Glu" | 
                               d15N.dat.long$AA.short=="Ala" | d15N.dat.long$AA.short=="Ile" | 
                               d15N.dat.long$AA.short=="Leu" | d15N.dat.long$AA.short=="Val" | 
                               d15N.dat.long$AA.short=="Pro", "Troph", "Source")

dfN<-d15N.dat.long
mod<-lm(d15N.value~AA.short+Treat.Int*Fraction, data=d15N.dat.long)
plot(allEffects(mod), par.strip.text=list(cex=0.7), par.settings=list(axis.text=list(cex=0.7)))

#dfN<-d15N.dat.long[!(d15N.dat.long$AA.short=="Thr"), ] # not good source, remove here
  • all AA pooled by fraction, showing d15N.CSIA_Fraction
######## Figures
pd <- position_dodge(0.5) #offset for error bars

df.mean<-aggregate(d15N.value~AA.short+Fraction, data=dfN, mean, na.rm=TRUE)
df.n<-aggregate(d15N.value~AA.short+Fraction, data=dfN, length)
df.SD<-aggregate(d15N.value~AA.short+Fraction, data=dfN, sd, na.rm=TRUE)
df.SD[is.na(df.SD)] <- 0
colnames(df.SD)[3]="SD"
df.mean<-cbind(df.mean, df.SD[3])
df.mean$Fraction<-factor(df.mean$Fraction, levels=c("host", "symb", "plank"))

Fig.formatting<-(theme_classic()) +
  theme(text=element_text(size=10),
        axis.line=element_blank(),
        legend.text.align = 0,
        legend.text=element_text(size=10),
        #legend.title = element_blank(),
        panel.border = element_rect(fill=NA, colour = "black", size=1),
        aspect.ratio=1, 
        axis.ticks.length=unit(0.25, "cm"),
        axis.text.y=element_text(
          margin=unit(c(0.5, 0.5, 0.5, 0.5), "cm"), colour="black", size=10), 
        axis.text.x=element_text(
          margin=unit(c(0.5, 0.5, 0.5, 0.5), "cm"), colour="black", size=8)) +
  theme(legend.key.size = unit(0.4, "cm")) +
  theme(aspect.ratio=1) +
  theme(panel.spacing=unit(c(0, 0, 0, 0), "cm"))

######
# all AA pooled by fraction
ggplot(df.mean, aes(x=AA.short, y=d15N.value)) +
  geom_errorbar(aes(ymin=d15N.value-SD, ymax=d15N.value+SD, color=Fraction), 
                size=.5, width=0, position=pd) +
  geom_point(size=3, pch=19,  position=pd, aes(color=Fraction)) +
  ggtitle(expression(paste(delta^{15}, N[AA], " by biological fraction"))) +
  coord_cartesian(ylim=c(15, -5)) +
  geom_vline(xintercept=7.5, linetype="solid", color = "gray") +
  annotate(geom="text", label="Trophic-AA", x=4, y=15, color="gray40") +
  annotate(geom="text", label="Source-AA", x=10, y=15, color="gray40") +
  xlab("Amino Acids") + 
  ylab(ylab(expression(paste(delta^{15}, N[AA], " (\u2030, AIR)")))) +
  scale_color_manual(values=c("coral", "springgreen3", "skyblue3")) +
  Fig.formatting

ggsave("figures/nitrogen/d15N.CSIA_Fraction.pdf", height=5, width=8, encod="MacRoman")
  • Fraction and treatment, showing d15N.CSIA_frac.trt
#################
df.mean<-aggregate(d15N.value~AA.short+Fraction+Treat.Int, data=dfN, mean, na.rm=TRUE)
df.n<-aggregate(d15N.value~AA.short+Fraction+Treat.Int, data=dfN, length)
df.SD<-aggregate(d15N.value~AA.short+Fraction+Treat.Int, data=dfN, sd, na.rm=TRUE)
colnames(df.SD)[4]="SD"
df.mean<-cbind(df.mean, df.SD[4])
df.mean$Fraction<-factor(df.mean$Fraction, levels=c("host", "symb", "plank"))

ggplot(df.mean, aes(x=AA.short, y=d15N.value)) +
  geom_point(size=3, aes(shape=Treat.Int, color=Fraction, group=Treat.Int)) +
    ggtitle(expression(paste(delta^{15}, N[AA], " by biological fraction, treatment"))) +
  coord_cartesian(ylim=c(15, -5)) + 
  geom_vline(xintercept=7.5, linetype="solid", color = "gray") +
  annotate(geom="text", label="Trophic-AA", x=4, y=15, color="gray40") +
  annotate(geom="text", label="Source-AA", x=10, y=15, color="gray40") +
  xlab("Amino Acids") +
  scale_color_manual(values=c("coral", "springgreen3", "skyblue3")) +
  ylab(ylab(expression(paste(delta^{15}, N[AA], " (\u2030, AIR)")))) +
  Fig.formatting

ggsave("figures/nitrogen/d15N.CSIA_frac.trt.pdf", height=5, width=8, encod="MacRoman")
  • all amino acids, showing d15N.CSIA_Trt.alone.pdf
##################
# all d15N amino acids

df.mean2<-aggregate(d15N.value~AA.short+Treat.Int, data=dfN, mean, na.rm=TRUE)
df.SD2<-aggregate(d15N.value~AA.short+Treat.Int, data=dfN, na.rm=TRUE, sd)
df.SD2[is.na(df.SD2)] <- 0
colnames(df.SD2)[3]="SD"
df.mean2<-cbind(df.mean2, df.SD2[3])

ggplot(df.mean2, aes(x=AA.short, y=d15N.value, group=Treat.Int)) +
  geom_errorbar(aes(ymin=d15N.value-SD, ymax=d15N.value+SD, color=Treat.Int), size=.5, width=0, position=pd) +
  geom_point(aes(color=Treat.Int), size=3, position=pd) +
  ggtitle(expression(paste(delta^{15}, N[AA], " by treatment"))) +
  coord_cartesian(ylim=c(15, -5)) + 
  geom_vline(xintercept=7.5, linetype="solid", color = "gray") +
  annotate(geom="text", label="Trophic-AA", x=4, y=15, color="gray40") +
  annotate(geom="text", label="Source-AA", x=10, y=15, color="gray40") +
  xlab("Amino Acids") +
  scale_color_manual(values=c("gray40", "darkgoldenrod1", "coral", "skyblue2")) +
  ylab(ylab(expression(paste(delta^{15}, N[AA], " (\u2030, AIR)")))) +
  Fig.formatting

ggsave("figures/nitrogen/d15N.CSIA_Trt.alone.pdf", height=5, width=8, encod="MacRoman")
  • all source and trophic AA, showing d15N.CSIA_TrSo
##################
# all source and trophic) AA
AA.means<-aggregate(d15N.value~AA.cat+Treat.Int+Fraction, data=dfN, mean, na.rm=TRUE)
AA.sd<-aggregate(d15N.value~AA.cat+Treat.Int+Fraction, data=dfN, sd, na.rm=TRUE)
colnames(AA.sd)[4]="SD"
AA.means<-cbind(AA.means, AA.sd[4])
AA.means$Fraction<-factor(AA.means$Fraction, levels=c("host", "symb", "plank"))

ggplot(AA.means, aes(x=Treat.Int, y=d15N.value, group=AA.cat, color=Fraction)) +
  geom_errorbar(aes(ymin=d15N.value-SD, ymax=d15N.value+SD), size=.5, width=0, position=pd) +
  geom_point(aes(color=Fraction, shape=AA.cat), size=3, position=pd) +
  ggtitle(expression(paste(delta^{15}, N[AA], " by biological fraction, Tr/So-AA"))) +
  coord_cartesian(ylim=c(12, 0)) + 
  scale_x_discrete(name ="Treatments", 
                   labels=c("Dark\nFed", "Light\nFed", "Light\nNot Fed")) +
  scale_color_manual(values=c("coral", "springgreen3",  "skyblue3")) +
  ylab(ylab(expression(paste(delta^{15}, N[AA], " (\u2030, AIR)")))) +
  Fig.formatting

ggsave("figures/nitrogen/d15N.CSIA_TrSo.pdf", height=5, width=8, encod="MacRoman")
  • source and trophic AA w/o glycine, serine and threonine, showing d15N.CSIA_TrSo.no.glyserthr
##################
# source and trophic AA w/o glycine  serine and threonine
dfN.trim<-d15N.dat.long[!(d15N.dat.long$AA.short=="Ser" | 
                            d15N.dat.long$AA.short=="Gly" | d15N.dat.long$AA.short=="Thr"), ]

AA.means<-aggregate(d15N.value~AA.cat+Treat.Int+Fraction, data=dfN.trim, mean, na.rm=TRUE)
AA.sd<-aggregate(d15N.value~AA.cat+Treat.Int+Fraction, data=dfN.trim, na.rm=TRUE, sd)
colnames(AA.sd)[4]="SD"
AA.means<-cbind(AA.means, AA.sd[4])
AA.means$Fraction<-factor(AA.means$Fraction, levels=c("host", "symb", "plank"))


ggplot(AA.means, aes(x=Treat.Int, y=d15N.value, group=AA.cat, color=Fraction)) +
  geom_errorbar(aes(ymin=d15N.value-SD, ymax=d15N.value+SD), size=.5, width=0, position=pd) +
  geom_point(aes(color=Fraction, shape=AA.cat), size=3, position=pd) +
  coord_cartesian(ylim=c(14, 0)) + 
  scale_x_discrete(name ="Treatments", 
                   labels=c("Dark\nFed", "Light\nFed", "Light\nNot Fed")) +
  ggtitle(expression(paste(delta^{15}, N[AA], " by biological fraction, Tr/So-AA, - Ser/Gly/Thr"))) +
  scale_color_manual(values=c("coral", "springgreen3",  "skyblue3")) +
  ylab(ylab(expression(paste(delta^{15}, N[AA], " (\u2030, AIR)")))) +
  Fig.formatting

ggsave("figures/nitrogen/d15N.CSIA_TrSo.no.glyserthr.pdf", height=5, width=8, encod="MacRoman")
  • threonine in host and symbiont (microbial source), showing d15N.CSIA_TrSo.thr
##################
# threonine in host and symbiont (microbial source)
dfN.thr<-d15N.dat.long[(d15N.dat.long$AA.short=="Thr"),]
AA.means<-aggregate(d15N.value~AA.cat+AA.short+Treat.Int+Fraction, data=dfN.thr, mean, na.rm=TRUE); AA.means
AA.sd<-aggregate(d15N.value~AA.cat+Treat.Int+Fraction, data=dfN.trim, na.rm=TRUE, sd)
colnames(AA.sd)[4]="SD"
AA.means<-cbind(AA.means, AA.sd[4])
AA.means$Fraction<-factor(AA.means$Fraction, levels=c("host", "symb", "plank"))

ggplot(AA.means, aes(x=Treat.Int, y=d15N.value, color=Fraction)) +
  geom_errorbar(aes(ymin=d15N.value-SD, ymax=d15N.value+SD), size=.5, width=0, position=pd) +
  geom_point(aes(color=Fraction), size=3, position=pd) +
  coord_cartesian(ylim=c(6, -6)) + 
  scale_x_discrete(name ="Treatments", 
                   labels=c("Dark\nFed", "Light\nFed", "Light\nNot Fed")) +
  ggtitle(expression(paste("Threonine ", delta^{15}, N[AA]))) +
  scale_color_manual(values=c("coral", "springgreen3", "skyblue3")) +
  ylab(ylab(expression(paste(delta^{15}, N[AA], " (\u2030, AIR)")))) +
  Fig.formatting

ggsave("figures/nitrogen/d15N.CSIA_TrSo.thr.pdf", height=5, width=8, encod="MacRoman")
Weighted means

These are the weighted means for trophic and source AA following Bradley et al. 2015. Weighted mean AA δ15N values

  • weighted means, showing wt.mean.d15N.CSIA
###########################
##################
#########

df.mean<-aggregate(d15N.value~AA.short+AA.cat+Fraction+Treat.Int, data=dfN, mean, na.rm=TRUE)
df.SD<-aggregate(d15N.value~AA.short+AA.cat+Fraction+Treat.Int, data=dfN, sd, na.rm=TRUE)
colnames(df.SD)[5]="SD"
df.mean<-cbind(df.mean, df.SD[5])
df.mean$mean.sd<-(df.mean$d15N.value/df.mean$SD)
df.mean$inv.sd<-(1/df.mean$SD)
# write.csv(df.mean, "wtmeans.csv") # use this to calculate weighted mean
# weighted mean is sum(mean.sd/inv.sd) for trophic AA, same for source AA
# delta.Tr.So (below) is difference in (weighted mean) Trophic AA - Source AA for host or symb, per treatment

#########
wt.mean<-read.csv("data/wt.means.d15N.csv")
wt.mean.df<-aggregate(wt.mean~AA.cat+Fraction+Treat.Int, data=wt.mean, mean, na.rm=TRUE)

pd <- position_dodge(0.0) #offset for error bars
ggplot(wt.mean.df, aes(x=Treat.Int, y=wt.mean)) +
  geom_point(aes(color=Fraction, shape=AA.cat), size=3, position=pd) +
  coord_cartesian(ylim=c(8, 0))+ 
  ggtitle(expression(paste("Weighted Mean ", delta^{15}, N[AA]))) +
  scale_color_manual(values=c("coral", "springgreen3")) +
  scale_x_discrete(name ="Treatments", 
                   labels=c("Dark\nFed", "Light\nFed", "Light\nNot Fed")) +
  ylab(ylab(expression(paste(delta^{15}, N[AA], " (\u2030, AIR)")))) +
  Fig.formatting

ggsave("figures/nitrogen/wt.mean.d15N.CSIA.pdf", height=5, width=8, encod="MacRoman")
  • delta trophic - source AA, showing wt.mean.d15N.TR.SO.CSIA
############
# delta trophic - source AA
wt.mean.df2<-aggregate(delt.Tr.So~AA.cat+Fraction+Treat.Int, data=wt.mean, mean, na.rm=TRUE)

ggplot(wt.mean.df2, aes(x=Treat.Int, y=delt.Tr.So)) +
  geom_point(aes(color=Fraction), size=3) +
  coord_cartesian(ylim=c(2, -5))+ 
  ggtitle("weighted mean d15N") +
  scale_color_manual(values=c("coral", "springgreen3")) +
  scale_x_discrete(name ="Treatments", 
                   labels=c("Dark\nFed", "Light\nFed", "Light\nNot Fed")) +
  ylab(ylab(expression(paste(delta^{15}, N[Trophic[AA]-Source [AA]], " (\u2030, AIR)")))) +
  Fig.formatting

ggsave("figures/nitrogen/wt.mean.d15N.TR.SO.CSIA.pdf", height=5, width=8, encod="MacRoman")
Sum V

Calculate Sum-V, McCarthy et al. 2007. The sum-V parameter is a proxy for total heterotrophic resynthesis. It is defined as the average deviation in the d15N values of the trophic amino acids Ala, Asp, Glu, Ile, Leu, and Pro.

  • showing d15N.sumV.CSIA
###########################
# dfN is dataframe
sV.df<-aggregate(d15N.value~AA.short+AA.cat+Fraction+Treat.Int, data=d15N.dat.long, mean, na.rm=TRUE)
sV.df.sd<-aggregate(d15N.value~AA.short+AA.cat+Fraction+Treat.Int, data=d15N.dat.long, sd, na.rm=TRUE)
colnames(sV.df.sd)[5]="SD"
sV.df$SD<-sV.df.sd$SD

# make dataframe for AA, that with su deviance = sum-V
sV.df2<-sV.df[c(sV.df$AA.short=="Ala" | sV.df$AA.short=="Glu" | sV.df$AA.short=="Asp" | 
                  sV.df$AA.short=="Ile" | sV.df$AA.short=="Leu" | sV.df$AA.short=="Pro"),]

write.csv(sV.df2, "sumV.csv")

sumVdf<-read.csv("data/sumV.csv")
sumVdf<-sumVdf[!(sumVdf$Treat.Int=="Plank"), ]

ggplot(sumVdf, aes(x=Treat.Int, y=sumV)) +
  geom_point(aes(color=Fraction), size=3) +
  coord_cartesian(ylim=c(5, 7))+ 
  ggtitle(expression(paste("Sum-V ", delta^{15}, N[AA]))) +
  scale_color_manual(values=c("coral", "springgreen3", "")) +
  scale_x_discrete(name ="Treatments", 
                   labels=c("Dark\nFed", "Light\nFed", "Light\nNot Fed")) +
  ylab(ylab(expression(paste(delta^{15}, N[Sum-V], "(\u2030, AIR)")))) +
  Fig.formatting

ggsave("figures/nitrogen/d15N.sumV.CSIA.pdf", height=5, width=8, encod="MacRoman")